home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-03-05 | 1.4 KB | 58 lines |
- /**
- * This class is the implementation of Portfolio Client
- * @author Rahul
- */
-
-
- import java.io.*;
-
- import org.omg.CORBA.*;
- import com.sun.CORBA.iiop.*;
-
- // This is the directory where the idl-to-java compiler put stuff
- import PortfolioManager.* ;
-
- public
- class PortfolioClient {
- /** ORB
- **/
- public
- static com.sun.CORBA.iiop.ORB theOrb_;
-
- public
- static PortfolioManager.Portfolio ref_;
-
- public
- static void main(String args[]) {
- try {
- // Get an orb object
- String[] paramList = new String[2];
- paramList[0] = "-ORBHost";
- paramList[1] = java.net.InetAddress.getLocalHost().getHostName();
- theOrb_ = new com.sun.CORBA.iiop.ORB(paramList, null);
-
- // Read IOR from file
- InputStream inf =
- new FileInputStream(System.getProperty("user.home") +
- System.getProperty("file.separator") +
- "Portfolio.ior") ;
-
- DataInputStream in = new DataInputStream(inf) ;
- String ior2 = in.readLine();
-
- // Get objref
- org.omg.CORBA.Object obj = theOrb_.string_to_object(ior2) ;
- ref_ = PortfolioManager.PortfolioHelper.narrow(obj);
-
- ref_.addStock("SUNW", (short)100, 33.50);
- System.out.println("Report: " + ref_.report());
-
- }
- catch (Exception ex) {
- ex.printStackTrace();
- System.out.println("Portfolio Client: Exception-> " + ex) ;
- }
- }
-
- }
-